<script type="text/javascript">
	$(function() {
	    $.fn.dataGridOptions.formSubFun("#form",'/modules/additional/upRate/domodify.html',"修改成功！","修改失败！");
	});
</script> 
<div class="popForm sForm">
	<form id="form"  method="post">
		<div class="formitm">
			<label class="lab">名称：</label>
			<div class="ipt"><input type="text" name="ruleName" value="${rule.ruleName!}" style="width:120px;" class="easyui-validatebox"  maxlength="15" data-options="required: true,validType:'maxLength[15]'"></div>
		</div>
		
		<div class="formitm">
			<label class="lab">有效期：</label>
			<div class="ipt"><input type="text" name="valitTime" value="${rule.valitTime!}" style="width:60px;" class="easyui-validatebox"  onkeyup="this.value=this.value.replace(/[^0-9]/g,'')" data-options="required: true, validType:'numOnly'" maxlength="3">天</div>
		</div>
		<div class="formitm">
			<label class="lab">名额：</label>
			<div class="ipt"><input type="text" name="payTotal"  value="${rule.payTotal!}" style="width:60px;" class="easyui-validatebox"  onkeyup="this.value=this.value.replace(/[^0-9]/g,'')" data-options="required: true, validType:'numOnly'" maxlength="6">份</div>
		</div>
		<div class="formitm">
			<label class="lab">状态：</label>
			<div class="ipt">
				<select name="isUse" id="isUse">
					<option value="2"<#if rule.isUse==2>selected="selected"</#if>  >未启用</option>
					<option value="1" <#if rule.isUse==1>selected="selected"</#if>>启用</option>
				</select>
			</div>
		</div>
	
		<div class="formitm">
			<label class="lab">发放方式：</label>
			<div class="ipt">
				<select name="payWay" id="payWay" onchange="showType()">
					<option value="1" <#if rule.payWay==1>selected="selected"</#if>  >固定值</option>
					<option value="2" <#if rule.payWay==2>selected="selected"</#if>>按投资比例</option>
				<!--  	<option value="3">随机</option>-->
				</select>
			</div>
		</div>
		<input type="hidden" name="id" value="${rule.id!}"/>
		<input type="hidden" name="realPayTotal" value="${rule.realPayTotal!}"/>
	
	</form>	
	
	<!-- S js动态增减的隐藏域 -->
	<!-- S 固定值 -->
	<div class="formitm" id="upApr" style="display:none;">
		<label class="lab">加息比例：</label>
		<div class="ipt"><input type="text" name="upApr"  value="${rule.upApr!}" style="width:60px;" class="easyui-validatebox"  onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" data-options="required: true, validType:'scoreRate[0.01,100]'" maxlength="5">%</div>
	</div>
	<!-- E 固定值 -->
	<!-- S 按投资比例 -->
	 <#if rateDetailList?? && (rateDetailList?size >0)>
	 <#assign ii=0/>
	 <div class="formitm" id="tenderMoney" style="display:none;">
		<#list rateDetailList as item>
			
		<#if ii==0>
		<ul class="tenderMoneyList">
			<li>
				<label class="lab">起始值：</label>
				<div class="ipt"><input type="text" name="dminmoney" value="${item.min}" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7">元</div>
			</li>
			
			<li>
				<label class="lab">结束值：</label>
				<div class="ipt"><input type="text" name="dmaxmoney" value="${item.max}" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7">元</div>
	
			</li>
			<li>
				<label class="lab">加息利率：</label>
				<div class="ipt"><input type="text" name="daprs" value="${item.rateApr}" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7">%</div>
			</li>
		</ul>
		<#else>
		<!--	S  删除列表隐藏域 -->
		<ul class="tenderMoneyList" >
			<li>
				<label class="lab">起始值：</label>
				<div class="ipt"><input type="text" name="dminmoney" value="${item.min}" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7">元</div>
			</li>
			
			<li>
				<label class="lab">结束值：</label>
				<div class="ipt"><input type="text" name="dmaxmoney" value="${item.max}" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7">元</div>
	
			</li>
			<li>
				<label class="lab">加息利率：</label>
				<div class="ipt"><input type="text" name="daprs" value="${item.rateApr}" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7">%</div>
			</li>
			<li><a href="javascript:;" class="removeList" title="删除">-</a></li>
		</ul>
		</#if>
		<!--	E  删除列表隐藏域 -->
		<#assign ii=ii+1/>
		</#list>

		<a  href="javascript:;" class="addList" title="添加">+</a>	
			
				
	</div>
			
			
	<#else>
	<div class="formitm" id="tenderMoney" style="display:none;">
		<ul class="tenderMoneyList">
			<li>
				<label class="lab">起始值：</label>
				<div class="ipt"><input type="text" name="dminmoney" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7">元</div>
			</li>
			
			<li>
				<label class="lab">结束值：</label>
				<div class="ipt"><input type="text" name="dmaxmoney" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7">元</div>
	
			</li>
			<li>
				<label class="lab">加息利率：</label>
				<div class="ipt"><input type="text" name="daprs" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7">%</div>
			</li>
		</ul>
	
		<a  href="javascript:;" class="addList" title="添加">+</a>		
	</div>
	</#if>
	<!--	S  删除列表隐藏域 -->
	<ul id="deleteList" class="tenderMoneyList" style="display:none;">
		<li>
			<label class="lab">起始值：</label>
			<div class="ipt"><input type="text" name="dminmoney" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7">元</div>
		</li>
		
		<li>
			<label class="lab">结束值：</label>
			<div class="ipt"><input type="text" name="dmaxmoney" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7">元</div>

		</li>
		<li>
			<label class="lab">加息利率：</label>
			<div class="ipt"><input type="text" name="daprs" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7">%</div>
		</li>
		<li><a href="javascript:;" class="removeList" title="删除">-</a></li>
	</ul>
	<!--	E  删除列表隐藏域 -->
	<!-- E 按投资比例 -->
</div> 	
	<script type="text/javascript">
	
	/*
	 * input金额输入判断
	 * type: 1 -- 整数 ，其他  -- 浮点数
	 * class:int_figure_required --整数，float_figure_required -- 浮点数
	 * 备注：如有动态添加的DOM元素，请用  $.parser.parse("#form");	//重新解析form表单
	 *     解析后再添加此js，否则不会生效（建议将调用js放在$.parser.parse("#form");的后面）
	 */
	function Inputlimit(obj,type){
		if(type==0){
			obj.value = obj.value.replace(/^0+(\d+)/, '$1'); //不能输入 类似00、01、0000001的数值
			obj.value = obj.value.replace(/[^\d.]/g,""); //清除"数字"和"."以外的字符
			obj.value = obj.value.replace(/^\./g,""); //验证第一个字符是数字而不是
			obj.value = obj.value.replace(/\.{2,}/g,"."); //只保留第一个. 清除多余的
			obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
			obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3'); //只能输入两个小数
		}
		if (type==1) {
			obj.value=obj.value.replace(/\D/g,'');
			obj.value = obj.value.replace(/^0+(\d+)/, '$1'); //不能输入 类似00、01、0000001的数值
		}
	}
	 
	function showType(){
		var value = $("#payWay").val();
		var $formId = $("#form");
		if(value==1){
			$("#form ").append($("#upApr").clone());
			$formId.find("#upApr").show(); 
			
			$formId.find("#tenderMoney").hide();
			$formId.find("#tenderMoney").remove();
			$.parser.parse("#form");	//重新解析form表单
		}
		if(value==2){	//区间比例
			
			
			$("#form ").append($("#tenderMoney").clone());
			$formId.find("#tenderMoney").show();
			$formId.find("#upApr").hide();
			$formId.find("#upApr").remove();
			$.parser.parse("#form");	//	重新解析form表单
			
			//	添加删除列表
			$("#form .addList").click(function(){
				$("#form  #tenderMoney").append($("#deleteList").clone());
				$("#form #tenderMoney .tenderMoneyList").css("display","block");
				$.parser.parse("#form");	//	重新解析form表单
				
				//	输入验证
				$(".int_figure_required").keyup(function(){
					Inputlimit(this,1);
				});
				
				$(".float_figure_required").keyup(function(){
					Inputlimit(this,0);
				});
			});
			
			
			$(".removeList").live("click",function(){	//	给动态生成的元素添加事件，应使用live
				 $(this).parent().parent().remove();
			});
		}
		

		//	输入验证
		$(".int_figure_required").keyup(function(){
			Inputlimit(this,1);
		});
		
		$(".float_figure_required").keyup(function(){
			Inputlimit(this,0);
		});
	}
	showType();
	</script>
	
	


